<?php

use think\facade\Route;

/** 接口路由 */

/* 课程点评 */
Route::group('base', function () {
    // 我的点评
    Route::get('comment/mine', 'myCommentsList');
    // 课程相关
    Route::group('<id>', function () { // <id>课程ID
        Route::post('comment$', 'addCourseComment'); // 添加课程点评
        Route::get('comment$', 'getCourseComments')->middleware(['withoutLogin']); // 课程点评列表
    })->pattern(['id' => '\d+']);
    // 点评评论
    Route::group('comment/<id>', function () {
        // <id>点评ID
        Route::put('like$', 'changeCommentLikeStatus'); // 点赞
        Route::delete('$', 'deleteCourseComment'); // 点赞
        Route::group('/reply', function () {
            Route::post('$', 'addCourseCommentReply'); // 添加点评评论
            Route::get('$', 'getCourseCommentReply')->middleware(['withoutLogin']); // 点评评论列表
        });
    })->pattern(['id' => '\d+']);
    Route::put('comment/reply/<id>/like$', 'changeCommentReplyLikeStatus')->pattern(['id' => '\d+']); // 点评的评论点赞
    Route::delete('comment/reply/<id>$', 'deleteCourseCommentReply')->pattern(['id' => '\d+']);

})->prefix('\app\course\service\base\Course@');

/** 后台管理 */
Route::group('admin/comment/<course_id>', function () {
    // 课程评论列表
    Route::get('list', '@commentList');
    Route::delete('<comment_id>/delete', '@deleteComment')->pattern(['comment_id' => '\d+']);
})
    ->prefix('\app\course\service\comment\admin\Comment')
    ->middleware(['adminRoute'])
    ->pattern(['course_id' => '\d+']);
